<script setup>
const props = defineProps({
  active: {
    type: Boolean,
    default: false
  }
})

const emit = defineEmits(['edit', 'delete'])
</script>

<template>
  <div class="aside-list" :class="{ active: active }">
    <span class="truncate">
      <slot></slot>
    </span>
    <el-button class="ml-auto px-1" type="primary" size="small" text @click="$emit('edit')">
      <el-icon><Edit /></el-icon>
    </el-button>
    <!-- 阻止冒泡事件 -->
    <span @click.stop="() => {}">
      <el-popconfirm
        title="是否要删除该分类"
        confirm-button-text="确认"
        cancel-button-text="取消"
        @confirm="$emit('delete')"
      >
        <template #reference>
          <el-button class="ml-auto px-1" type="primary" size="small" text>
            <el-icon><CloseBold /></el-icon>
          </el-button>
        </template> </el-popconfirm
    ></span>
  </div>
</template>

<style>
.aside-list {
  border-bottom: 1px solid #f4f4f4;
  @apply flex items-center  p-3 text-sm text-gray-600 cursor-pointer;
}
.aside-list:hover,
.active {
  @apply bg-blue-50;
}
</style>
